package top.yangyitao.controller;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import top.yangyitao.dto.UserDto;
import top.yangyitao.entity.Icon;
import top.yangyitao.service.IconService;

@RestController
public class PageController {
	@Autowired
	private IconService iconService;

	@RequestMapping("/")
	public ModelAndView index() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/login.html");
		return mv;
	}

	@RequiresAuthentication
	@RequestMapping("/index_html")
	public ModelAndView showIndex() {
		ModelAndView mv = new ModelAndView();
		Subject subject = SecurityUtils.getSubject();
		mv.addObject("userDto",(UserDto)subject.getSession().getAttribute("userDto"));
		mv.setViewName("/index.html");
		return mv;
	}
	
	@RequestMapping("/getFontAweSome")
	public List<Icon> getFontAweSome() {
		return iconService.getFontAweSome();
	}

	@RequestMapping("/getGlyphicons")
	public List<Icon> getGlyphicons() {
		return iconService.getGlyphicons();
	}

}
